home *** CD-ROM | disk | FTP | other *** search
- /* This file contains mmap() and munmap() routines that (sorta) work
- on the NeXT. */
-
-
- #include <sys/types.h>
- #include <sys/mman.h>
- #include <mach/mach.h>
- #include <fcntl.h>
- #include <stdio.h>
-
-
- /* mmap() replacement for NeXTStep. NeXTStep has mmap(), but it
- requires that virtual memory be allocated before it is called.
- I use a #define in cb.h to redefine mmap() in the normal QRZ!
- routines to use next_mmap(). Also see nsort.c. Even with this
- fix, nsort doesn't work properly on the NeXT w/o some additional
- help :-(. BEC (AC4XO) */
-
- caddr_t next_mmap(caddr_t addr,size_t len,int prot, int flags, int filedes,
- off_t off)
- {
- caddr_t mi;
- if(vm_allocate(task_self(),(vm_address_t *) &mi,len,TRUE)!=KERN_SUCCESS)
- return NULL;
- if(mmap(mi,len,prot,flags,filedes,off)==-1) return NULL;
- return mi;
- }
-
-
- /* munmap() replacement for NeXTStep. Just deallocate the virtual
- memory. */
-
- void munmap(void *addr,int size)
- {
- if(vm_deallocate(task_self(),(vm_address_t) addr,size)!=KERN_SUCCESS) {
- perror("vm_deallocate");
- exit(1);
- }
- }
-